<script type="text/javascript">
function readCardBySingleCard(){
	var flag=activeCPU();
	if(flag){
		flag=qzsmkocx.GetSmkNo();//获取市民卡号
	}
	var citizenCardNo=""
	if(flag){
		citizenCardNo=qzsmkocx.GetRetValue().split(",")[0];
		var citizenNoArray = $("input[name='newCitizenCardNo']").val();
		
		
		if(citizenNoArray){
			console.log("citizenNoArray==>"+citizenNoArray);
			var index = citizenNoArray.indexOf(citizenCardNo);
			if(index>=0){
				alertMsg.warn("请勿重复读取卡片！")	
				return false;
			}
		}
		console.log("读取后的市民卡数组==>"+$("input[name='newCitizenCardNo']").val());
		//通过市民卡号获取数据
		$.post("inventorymanagement/queryCardControl",{citizenCardNo:citizenCardNo},function(json){
				var list=json.list;
				var flag=json.flag;
				var citizenNo = "";
				var content="";
				if(flag=="false"){
					alertMsg.warn("卡片信息有误，请确认是否是预制空白/成品卡未发行！")
					return false;
				}
				if(list){
					for(var i=0;i<list.length;i++){
						var cardpCode = list[i].cardpCode;
						console.log("cardpCode===>"+cardpCode);
						if(i==0){
							citizenNo = list[0].citizenCardNo;
						}else{
							citizenNo = citizenNo +"#"+list[i].citizenCardNo;
						}
						
						
						console.log("citizenNo===>"+citizenNo)
						var value=list[i].citizenCardNo+"#"+cardpCode;
						content+="<tr align='center'>"
							     +"<td><input name='handtasked' onclick='test(this)' value="+value+" type='checkbox'></td>"
							     +"<td>"+[i+1]+"</td>"
							     +"<td>"+list[i].citizenCardNo+"</td>"
							     +"<td>"+cardpCode+"</td>"
							     +"</tr>"
							  
					
				}
				}	
				$("input[name='newCitizenCardNo']").val(citizenNo);
				$("#cardhand").html(content);
				var $p = $("#cardHanding");
			//	console.log("$p===>"+$p.html());
				initUI($p);
		},"json")	
	}else{
		checkError(getError());
	}
}
function checkBoxAll(){
	if($("input[name='handtasked']:checked").length < 1){
		 alertMsg.warn("您未选择数据！")	
		 return false;
	}
	
	/* var parm="";
	var array;
	$("input[name='handtasked']:checked").each(function(n,item){
		array=$(this).val().split(",")
		parm=array[1]+","+parm;
		
	})	
	//alert('parm==>'+parm);
	$("input[name='parm']").val(parm); */
	//默认全选中
	
}
function deleteCard(){
	if($("input[name='handtasked']:checked").length < 1){
		 alertMsg.warn("您未选择数据！")
		 return false;
	 }
	var parm="";
	var array;
	$("input[name='handtasked']:checked").each(function(n,item){
		array=$(this).val().split("#");
		if(n==0){
			parm = array[0];
		}else{
			parm=parm + "#" + array[0];
		}
		
	})
	$.post("inventorymanagement/deleteCard",{parm:parm},getCardHand,"json");
}	
</script>	

<div class="pageHeader ">
		<div class="searchBar">
			<table class="searchContent">
			<tr>
				<td><label>测试卡能否读:</label></td>
				<td><input type="button" value="读卡" onclick="readCardBySingleCard()"></td>
				<td><input name = "newCitizenCardNo" type="hidden" value=""></td>
			</tr>
			</table>
		</div>
</div>

<form method="post" action="inventorymanagement/handRegister" class="pageForm required-validate" onsubmit="return validateCallback(this,printViewPageAjaxDone);" >

<div class="panelBar">
		<ul class="toolBar">
			<li><a class="delete" onclick="return deleteCard();"><span>删除</span></a></li>
		</ul>
	</div>

<div class="pageContent" >
 <div id="cardHanding">
		<table class="table" width="800" layoutH="500">

			<thead>

				<tr>

					<th width="5%" align="center"><input type="checkbox" id="cardReceiv" name="cardReceivingtaskedByTotal" group="handtasked" class="checkboxCtrl"></th>
					<th width="8%" align="center">序号</th>
					<th width="20%" align="center">市民卡号</th>
					<th width="15%" align="center">卡产品代码</th>
                    
				</tr>

			</thead>

			<tbody id="cardhand">
			</tbody>
		</table>
</div>
	<input name="parm" type="hidden">
		<div class="formBar">
			<ul>
				<li>
				<div class="buttonActive" ><div class="buttonContent" ><button id="subTask" onclick="return checkBoxAll()" type="submit">上缴出库</button></div></div>
				</li>
			</ul>
			
		</div>
	</div>
</form>

	



